<!--_meta 作为公共模版分离出去-->
{include file="public/meta"}
<!--/meta 作为公共模版分离出去-->
<title>添加活动</title>
<link type="text/css" href="__PUBLIC__/css/datePicker.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/codebase/GooCalendar.css"/>

<script type="text/javascript">
function toBase64(file, fun) {
        //参数file为input获取到的file数组第一项，fun向外传递转换成功的base64编码
        var reader = new FileReader();
        if (file) {
            reader.readAsDataURL(file);
            reader.onload = function () {
                fun(this.result);
            }
        }
    }

</script>
</head>
<body>
<div class="page-container">
    <form action="{:url('GuideActivity/publish')}" method="post" enctype="multipart/form-data" class="form form-horizontal" id="form-data-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">活动名称：</label>
            <div class="formControls col-xs-4 col-sm-5">
                <input type="text" class="input-text" value="" placeholder="" id="name" name="name">
            </div>
        </div>
         <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">活动金额：</label>
            <div class="formControls col-xs-4 col-sm-5">
                <input type="text" class="input-text" value="" placeholder="" id="price" name="price">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>活动分类：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                <select name="cid" class="select">
                <option value="0">选择分类</option>
                     {foreach name="actype" item="val"}
                        <option  value='{$val['classifyId']}'>{$val['classifyName']}</option>
                   {/foreach}   
                </select>
                </span>
            </div>
        </div>
       <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">活动图片：</label>
            <div class="formControls col-xs-4 col-sm-5">
                <label class="upload_lable" for="file_img"><img id="goodsThums" src="__PUBLIC__/ic_ph.png"/></label>
                <input type="file" name="img" id="file_img" value="" hidden="hidden"/>
            </div>
        </div>
     <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">发布日期：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" name="time_from"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" id="datemin" class="input-text Wdate">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">结束日期：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text"  name="time_to" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" id="datemax" class="input-text Wdate">
            </div>
        </div>
         <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">报名截止时间：</label>
            <div class="formControls col-xs-4 col-sm-5">
                 <input type="text"  name="upTo_time" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" id="datemax" class="input-text Wdate">
            </div>
        </div> 
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">活动地点</label>
            <div class="formControls col-xs-4 col-sm-5">
                <input type="text" name="cityName" id="cityName" placeholder="" value="" class="input-text">
            </div>
        </div>
          <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">活动详情地点</label>
            <div class="formControls col-xs-4 col-sm-5">
                <input type="text" name="location" id="location" placeholder="" value="" class="input-text">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">活动特色：</label>
            <div class="formControls col-xs-8 col-sm-9"> 
                <script id="editor" name="activityDesc" type="text/plain" style="width:100%;height:400px;"></script> 
            </div>
        </div> 
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">活动细节：</label>
            <div class="formControls col-xs-4 col-sm-5">
                <textarea name="activityDetail" cols="90" rows="10"   placeholder="说点什么..." dragonfly="true" onKeyUp="textarealength(this,100)"></textarea>
                <p class="textarea-numberbar"></p>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">活动须知：</label>
            <div class="formControls col-xs-4 col-sm-5">
                <textarea name="actiivityNotice" cols="" rows="" class="textarea"  placeholder="说点什么..." dragonfly="true" onKeyUp="textarealength(this,100)"></textarea>
                <p class="textarea-numberbar"></p>
            </div>
        </div>
          
         <div class="row cl">
            <div class="col-xs-4 col-sm-5 col-xs-offset-4 col-sm-offset-2">
                <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;返回列表&nbsp;&nbsp;</button>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button id="bt_sub" class="btn btn-primary radius" type="button">&nbsp;&nbsp;创建&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
<!--_footer 作为公共模版分离出去-->
{include file="public/footer"}
<!--/_footer /作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUB__/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="__PUB__/webuploader/0.1.5/webuploader.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/js/jquery.datePicker-min.js"></script>
<script type="text/javascript" src="__PUB__/ueditor/1.4.3/ueditor.config.js"></script> 
<script type="text/javascript" src="__PUB__/ueditor/1.4.3/ueditor.all.min.js"> </script> 
<script type="text/javascript" src="__PUB__/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<!-- <script  type="text/javascript" src="__PUBLIC__/codebase/GooFunc.js"></script>
<script  type="text/javascript" src="__PUBLIC__/codebase/GooCalendar.js"></script> -->
<script type="text/javascript">
$(function(){  
$('#file_img').change(function (){
    var file_img=$(this);
    var img = $('#goodsThums');
    if (file_img[0].files[0].type.indexOf("image") == -1) {
        file_img.val("");
        img.attr('src',"{{ asset('static/ic_ph.png') }}");
        layer.msg('请选择图片类型的文件!', {icon: 7, time: 1000});
    } else {
        var files = file_img[0].files[0];
        toBase64(files, function (res) {
            img.attr('src',res);
        })
    }
});
$('#bt_sub').click(function () {
            var bt_sub = $(this);
            // var title = $('#title').val();
            // if (title == '' || title == undefined) {
            //     layer.msg('请填写广告标题!', {icon: 7, time: 1000});
            //     return false;
            // }
            bt_sub.attr('disabled', 'disabled');
            var formData = new FormData();
            formData.append('img',$("#file_img")[0].files[0]);
            $.each($("#form-data-add").serializeArray(), function (i, field) {
                formData.append(field.name, field.value);
            });
            $.ajax({
                url: $('#form-data-add').attr('action'),
                type: 'POST',
                data: formData,
                processData: false,// 告诉jQuery不要去处理发送的数据
                contentType: false,// 告诉jQuery不要去设置Content-Type请求头
                beforeSend: function () {
                    layer.msg('正在上传，请不要刷新或关闭页面!', {icon: 7, time: 1000000});
                },
                success: function (res) {
                    if (res.state == 1) {
                        window.parent.layer.msg(res.msg, {icon: 1, time: 1000});
                        setTimeout(function () {
                            window.parent.location.reload();
                        }, 1200);
                    }else {
                        window.parent.layer.msg(res.msg, {icon: 1, time: 1000});
                        setTimeout(function () {
                            window.parent.location.reload();
                        }, 1200);
                    }
                },
                error: function (res) {
                    layer.msg('网络错误，请关闭重试!', {icon: 2, time: 1000});
                    bt_sub.removeAttr('disabled');
                }
            });
        });
var ue = UE.getEditor('editor');
});
</script>
</body>
</html>